/*************************************************************************
	> File Name: oj-195_luffy_callnum.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年11月02日 星期一 00时03分36秒
 ************************************************************************/

#include <iostream>
using namespace std;

int n, m, id[100005], num;

int bs(int x) {
    int l = 0, r = n - 1, mid;
    while (l != r) {
        mid = (l + r + 1) / 2;
        if (id[mid] == x) return id[mid];
        if (id[mid] > x) r = mid - 1;
        else l = mid;
    }
    return id[l];
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> id[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> num;
        if (i > 0) cout << " ";
        if (num <= id[0]) {
            cout << id[0];
        }
        else if (num >= id[n - 1]) {
            cout << id[n - 1];
        }
        else {
            cout << bs(num);
        }
    }
    return 0;
}
